{include file="header.html"}
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/highcharts/highcharts.js" ></script>
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/statistics.js" ></script>
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/jquery.ui/jquery.ui.js" ></script>
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/jquery.ui/i18n/zh-CN.js" ></script>
<script charset="utf-8" type="text/javascript" src="../includes/libraries/javascript/timepicker/js/jquery-ui-timepicker-addon.js" ></script>
<link rel="stylesheet" type="text/css" href="/includes/libraries/javascript/jquery.ui/themes/ui-lightness/jquery.ui.css"  />

{include file=subnav.html}
<div id="rightTop">
    <p>{$lang.ad}</p>
    <ul class="subnav">
        <li><a class="btn1" href="index.php?app=discount_activity">{$lang.manage}</a></li>
        <li><span>{$lang.edit}</span></li>
    </ul>
</div>

<div class="info">
    <form id="theme_form" method="post" enctype="multipart/form-data">
        <table  width="100%" cellspacing="0" class="dataTable">
            <!--<tr>-->
                <!--<th class="paddingT15">-->
                    <!--选择图片:</th>-->
                <!--<td class="paddingT15 wordSpacing5">-->
                    <!--<input class="infoTableFile2" id="banner_url" type="file" name="group_url" value="{$info.group_url}"/>-->
                    <!--&lt;!&ndash;{if $info.group_url}&ndash;&gt;-->
                    <!--<img class="show_image" src="{res file=style/images/preview.png}" />-->
                    <!--<div style="position:absolute; display:none"><img src="{$site_url}/{$info.group_url}?{$random_number}" /></div>-->
                    <!--&lt;!&ndash;{/if}&ndash;&gt;-->
                <!--</td>-->
            <!--</tr>-->
            <tr>
                <th class="paddingT15">
                    备注:</th>
                <td class="paddingT15 wordSpacing5" >
                    <div class="left">
                        <input class="txt"  type="text" value="{$data.remark}" id="remark" name="remark">
                    </div>
                </td>
            </tr>
            <tr>
                <th class="paddingT15">
                    设置开始时间:</th>
                <td class="paddingT15 wordSpacing5" >
                    <div class="left">
                        <input class="txt date" readonly type="text" value="{$data.start_time|date:Y-m-d H:i:s}" id="start_time" name="start_time">
                    </div>
                </td>
            </tr>
            <tr>
                <th class="paddingT15">
                    设置结束时间:</th>
                <td class="paddingT15 wordSpacing5" >
                    <div  class="left">
                        <input class="txt date" readonly type="text" value="{$data.end_time|date:Y-m-d H:i:s}" id="end_time" name="end_time">
                    </div>
                </td>
            </tr>
            <tr id="sort_value">
                <th class="paddingT15"> 填写折扣值:</th>
                <td class="paddingT15 wordSpacing5" >
                    <input class="infoTableFile2" id="discount" type="number" name="discount" placeholder="1~100" oninput="if(value > 100 || value < 1 ){alert('非法输入！');value = ''}"/>%
                </td>
            </tr>
            <tr>
                <th class="paddingT15">选择商品:</th>
                <td class="paddingT15 wordSpacing5"><button class="formbtn cart-add" type="button">选择商品</button></td>
            </tr>
            <tr class="tatr1" id="after">
                <td>商品名称</td>
                <td>总库存</td>
                <td>仓库</td>
                <td>市场价</td>
                <td>香港直邮仓标价|折扣</td>
                <td>国内仓标价|折扣</td>
                <td>现价</td>
                <td>活动价</td>
                <!--<td>税费</td>-->
                <td>年代</td>
                <td>国际码</td>
                <td>排序</td>
                <td>默认图</td>
                <td>操作</td>
            </tr>

            <!--{foreach from=$info item=bg}-->
                <tr class="tatr1">
                    <td width="80px" >{$bg.goods_name}</td>
                    <td width="20px">{$bg.total_inventory}</td>
                    <td width="70px">{$bg.stock_name}</td>
                    <td width="25px">{$bg.market_price}</td>
                    <td width="80px">{$bg.hong_kong_price|0.00}|{$bg.hong_kong_discount}</td>
                    <td width="60px">{$bg.domestic_price|0.00}|{$bg.domestic_discount}</td>
                    <td width="40px">{$bg.price}</td>
                    <td width="40px"></td>
                    <td width="40px">{$bg.times|default='无'}</td>
                    <td width="40px">{$bg.international_code}</td>
                    <td width="40px">
                        <input style="width: 40px;" name="goodsSorts[{$bg.goods_id}]" type="text" class="infoTableInput2 sort_order"  value="{$bg.sort_order}">
                    </td>
                    <td width="50px" class="table-center"><img  height="80" src="{$bg.default_image}" /></td>
                    <td width="40px">
                        <input type="checkbox" checked style="display: none" value="{$bg.goods_id}" name="goods">
                        <img style="margin-right: 10px;width:15px;height: 15px;" src="templates/style/images/close.gif" onclick="dropGoods(this)" fieldname="mall_recommended" fieldid="{$bg.goods_id}" fieldvalue="1" title="{$lang.editable}"/>
                    </td>
                </tr>

                    <!--{foreach from=$bg.specInfo item=spec}-->
                        <tr class="{$bg.goods_id}">
                            <td width="80px">规格</td>
                            <td width="20px">{$spec.stock}</td>
                            <td width="70px">{$spec.spec_3}</td>
                            <td width="25px">{$bg.market_price}</td>
                            <td width="80px">{$bg.hong_kong_price|0.00}|{$bg.hong_kong_discount}</td>
                            <td width="60px">{$bg.domestic_price|0.00}|{$bg.domestic_discount}</td>
                            <td width="40px">{$spec.price}</td>
                            <td width="20px" >
                                <input style="color:red" attr-price="{$spec.price}" style="width: 40px;" class="discount" name="price[]" type="text" class="infoTableInput2" value="{$spec.discount_price|0.00}">
                                <input type="hidden" name="spec[]" value="{$spec.spec_id}">
                                <input name="goods_arr[]" type="hidden" class="infoTableInput2" value="{$bg.goods_id}">
                                <input name="consolidated_tax[]" type="hidden" class="infoTableInput2" value="{$bg.consolidated_tax}">
                            </td>
                            <td width="80px">{$bg.times|default='无'}</td>
                            <td width="80px">{$spec.sku}</td>
                            <td width="80px"></td>
                            <td class="table-center"><img  height="80" src="{$spec.image}" /></td>
                        </tr>
                    <!--{/foreach}-->
                <!--{/foreach}-->
            <input id="goods_id" name="goods_id" style="display: none" value="{$ids}">
            <tr>
                <th></th>
                <td class="ptb20">
                    <input class="formbtn" type="submit" name="Submit" value="{$lang.submit}" />
                    <input class="formbtn" type="reset" name="Submit2" value="{$lang.reset}" />
                </td>
            </tr>
        </table>
    </form>
    <div class = "bg-model" style="position:absolute;top:0%;left:0%;display:none;background:rgba(0,0,0,0.3);width:100%;height:100%;position:fixed;z-index:9999">
        <iframe src="index.php?app=discount_activity&act=choicesGoods" id="goods_page" width="90%" height="90%"></iframe>
    </div>
</div>
<script>
</script>
{include file="footer.html"}
<script>
    // var goods_id = '';
    $(function () {
        $(".show_image").mouseover(function () {
            $(this).next("div").show();
        });
        $(".show_image").mouseout(function () {
            $(this).next("div").hide();
        });
        // $("#discount").bind('input propertychange',function(){
        $("#discount").change(function(){
            var num = $(this).val();
            if(num != 0){
                $('.discount').each(function(){
                    var obj = $(this);
                    var price = $(this).attr('attr-price');
                    var discount_price = (price * num * 0.01).toFixed(2)
                    obj.val(discount_price);

                    // var spec_3value = $(this).attr('attr-spec_3value');
                    // var consolidated_tax = $(this).attr('attr-consolidated_tax');
                    //
                    // var tax_price = 0.00;
                    // if(spec_3value != 25){
                    //     tax_price = (consolidated_tax * discount_price).toFixed(2)
                    // }
                    // console.log(tax_price);
                    // $(".tax_price").val(tax_price);

                })
            }else{
                $('.discount').each(function(){
                    var obj = $(this);
                    obj.val(obj.val());
                })
            }

        });
        $('#start_time').datetimepicker({
            format: 'yyyy-mm-dd hh:ii:ss',
            autoclose: true,
            minView: 0,
            language : 'zh-CN',
            minuteStep:1,
        });
        $('#end_time').datetimepicker({
            format: 'yyyy-mm-dd hh:ii:ss',
            autoclose: true,
            minView: 0,
            language : 'zh-CN',
            minuteStep:1
        });
    })
    $(".cart-add").click(function () {
        $("iframe").contents().find(".checkitem:checked");
        $("iframe").contents().find(".checkitem:checked").each(function () {
            $(this).removeAttr('checked');
        })
        $("iframe").contents().items = '';
        $(".bg-model").fadeTo(300,1)
        //隐藏窗体的滚动条
        $("body").css({ "overflow": "hidden" });
    });


    //模态框OK按钮点击事件
    // $(".bg-model-ok").click(function () {
    //     $(".bg-model").hide();
    //     //显示窗体的滚动条
    //     $("body").css({ "overflow": "visible" });
    // }).hover(function () {
    //     $(this).css({ "backgroundColor": "#8CC8C8" });
    // }, function () {
    //     $(this).css({ "backgroundColor": "#8CD4E6" });
    // });
    // $("#enter").click(function () {
    //     var items = '';
    //     var name = '';
    //     $('.checkitem:checked').each(function(){
    //         items += this.value + ',';
    //         name += $(this).attr('attr-name') + ','
    //     });
    //     items = items.substr(0, (items.length - 1));
    //     name = name.substr(0, (name.length - 1));
    //     var items_arr = items.split(',');
    //     var name_arr = name.split(',');
    //     for(var i in items_arr){
    //         $(".choose_goods").append('<label style="padding: 5px; border:1px solid #e3e3e3" name="goods" value="'+items_arr[i]+'">'+name_arr[i]+'</label><input type="checkbox" checked style="display: none" value="'+items_arr[i]+'" name="goods"><img style="margin-right: 10px;width:15px;height: 15px;" src="templates/style/images/close.gif" onclick="dropGoods(this' +
    //             ')" fieldname="mall_recommended" fieldid="{$goods.goods_id}" fieldvalue="1" title="{$lang.editable}"/>');
    //     }
    //     $('#goods_id').val($('input[name="goods"][type=checkbox]:checked').map(function(){return this.value}).get().join(','));
    //     $(".bg-model").hide();
    //     //显示窗体的滚动条
    //     $("body").css({ "overflow": "visible" });
    // })
    function dropGoods(obj) {
        var fieldid = $(obj).attr('fieldid');
        var str = '.'+fieldid;
        $(obj).parent().parent().remove();
        $(str).remove();
        $(obj).remove()
        $('#goods_id').val($('input[name="goods"][type=checkbox]:checked').map(function(){return this.value}).get().join(','));
    }

</script>
